// 配置路由
// 导入vue-router并安装
import VueRouter from 'vue-router'

// 导入相应的子组件
import HomeContainer from './components/tabbars/HomeContainer.vue'
import ContactContainer from './components/tabbars/ContactContainer.vue'
import CartContainer from './components/tabbars/CartContainer.vue'
import SearchContainer from './components/tabbars/SearchContainer.vue'
// 导入首页九宫格二级路由-新闻列表组件
import newsList from './components/news/newsList.vue'
// 导入新闻内容组件
import newsInfo from './components/news/newsinfo.vue'
// 导入图片分享组件
import PhotoList from './components/photos/PhotoList.vue'
// 导入图片信息组件
import PhotoInfo from './components/photos/photoinfo.vue'
// 导入商品列表组件
import GoodsList from './components/goods/GoodsList.vue'
// 导入商品信息组件
import GoodsInfo from './components/goods/GoodsInfo.vue'
// 导入商品描述组件
import GoodsDesc from './components/goods/GoodsDesc.vue'
// 导入商品评论组件
import GoodsComment from './components/goods/GoodsComment.vue'

const router = new VueRouter({
    // 给 router-link 的 to 属性的匹配
    routes: [
        { path: '/', redirect: '/home' },
        { path: '/home', component: HomeContainer },
        { path: '/contact', component: ContactContainer },
        { path: '/cart', component: CartContainer },
        { path: '/search', component: SearchContainer },
        // 九宫格-新闻资讯
        { path: '/home/newslist', component: newsList },
        { path: '/home/newsinfo/:id', component: newsInfo, props: true }, // 开启传参
        // 九宫格-图片分享
        { path: '/home/photolist', component: PhotoList },
        { path: '/home/photolist/:imgid', component: PhotoInfo, props: true },
        // 九宫格-商品购买
        { path: '/home/goodslist', component: GoodsList },
        { path: '/home/goodslist/:goodsid', component: GoodsInfo, props: true },
        { path: '/home/goodsdesc/:goodsid', component: GoodsDesc, props: true },
        { path: '/home/goodscomment/:goodsid', component: GoodsComment, props: true },
    ],
    // 为选中链接添加类名的属性
    linkActiveClass: 'mui-active',

})

export default router